#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author : gao
# Time : 2020/7/6 23:24

"""
    文件说明：使用序列化进行存取决策树字典
"""

import pickle
import os

def storeTree(treeDict,file='./TreePickled/default.tree'):
    with open(file,'wb') as fo:
        pickle.dump(treeDict,fo)
    print('持久化结束')

def grabTree(file='./TreePickled/default.tree'):
    with open(file,'rb') as fo:
        return pickle.load(fo)

if __name__ == '__main__':
    dict ={'有自己的房子': {0: {'有工作': {0: 'no', 1: 'yes'}}, 1: 'yes'}}
    storeTree(dict)
    print(grabTree())